﻿#include "Note.h"
#include <array>



constexpr std::array<std::pair<const char*, const char*>, NOTE_DLG_TYPE_COUNT> note_icon_mapping
{
	std::pair{R"(#note_icon
{
	border-image: url(:/pic/warn1);
})","提示"},
	std::pair{R"(#note_icon
{
	border-image: url(:/pic/warn3);
})","信息"},
	std::pair{R"(#note_icon
{
	border-image: url(:/pic/warn2);
})","警告"},
	std::pair{R"(#note_icon
{
	border-image: url(:/pic/error);
})","错误"},
};

Note::Note(const QString& msg, NOTE_DLG_TYPE type, QWidget* parent) :
	BaseDlg(parent, note_icon_mapping[type].second)
{
	this->setupUi(ui);
	ui.note_content->setText(msg);
	ui.note_icon->setStyleSheet(note_icon_mapping[type].first);
}

Note::Note(const QString& title, const QString& msg, const QString& icon) :
	BaseDlg(nullptr, title)
{
	this->setupUi(ui);
	ui.note_content->setText(msg);
	ui.note_icon->setStyleSheet(icon);

}

Note::~Note()
{
}

void Note::NoteDlg(const QString& msg)
{
	Note nt{ msg,NOTE_DLG_TYPE_NOTE };
	nt.showDialog();
}

void Note::InfoDlg(const QString& msg)
{
	Note nt{ msg,NOTE_DLG_TYPE_INFO };
	nt.showDialog();
}

void Note::WarnDlg(const QString& msg)
{
	Note nt{ msg,NOTE_DLG_TYPE_WARN };
	nt.showDialog();
}

void Note::ErrorDlg(const QString& msg)
{
	Note nt{ msg,NOTE_DLG_TYPE_ERROR };
	nt.showDialog();
}
